package com.tutu.carousel.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tutu.carousel.mapper.CarouselMapper;
import com.tutu.carousel.service.CarouselService;
import com.tutu.commons.pojo.Carousel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Program: b2c-cloud-store
 * @Description:
 * @Author: JK.TuTu
 * @Version: 1.0
 * @Create: 2022-12-14 17:05
 **/
@Service
public class CarouselServiceImpl extends ServiceImpl<CarouselMapper, Carousel> implements CarouselService {

    @Autowired
    private CarouselMapper carouselMapper;
    /**
     * 获取轮播图信息
     * @return 返回结果实体 对象
     */
    @Override
    public List<Carousel> getCarousel() {
        LambdaQueryWrapper<Carousel> queryWrapper = new LambdaQueryWrapper<>();
        Page<Carousel> page=new Page<>(0,6);
        queryWrapper.orderByDesc(Carousel::getPriority);
        this.page(page, queryWrapper);
        return page.getRecords();
    }
}